from owl_Api import *
import shutil
import os

# 目标owl地址
event_owl_path = r"cantonowl\Event.owl"
personage_owl_path = r"cantonowl\Personage.owl"
location_owl_path = r"cantonowl\Location.owl"
time_owl_path = r"cantonowl\Time.owl"
relic_owl_path = r"cantonowl\Relic.owl"
recall_owl_path = r"cantonowl\Recall.owl"

# model built
owl_model = Parse_Owl()
event_dic, event_ind_start, event_ind_end = owl_model.get_individuals_dic(event_owl_path)
personage_dic, personage_ind_start, personage_ind_end = owl_model.get_individuals_dic(personage_owl_path)
location_dic, location_ind_start, location_ind_end = owl_model.get_individuals_dic(location_owl_path)
time_dic, time_ind_start, time_ind_end = owl_model.get_individuals_dic(time_owl_path)
relic_dic, relic_ind_start, relic_ind_end = owl_model.get_individuals_dic(relic_owl_path)
recall_dic, recall_ind_start, recall_ind_end = owl_model.get_individuals_dic(recall_owl_path)

# entities list
print("relic_owl实体数量:{}，集合:{}\n".format(len(relic_dic.keys()),relic_dic.keys()))
relic_list = list(relic_dic.keys())

def remove_file(old_path, new_path):
    """
    文件从一个文件夹转移到另一个文件夹
    :param old_path:
    :param new_path:
    """
    print(old_path)
    print(new_path)
    filelist = os.listdir(old_path) #列出该目录下的所有文件,listdir返回的文件列表是不包含路径的。
    relicList = []
    for i in filelist:
        for j in relic_list:
            if(j in i):
                relicList.append(i)
    print(relicList)
    for file in relicList:
        try:
            src = os.path.join(old_path, file)
            dst = os.path.join(new_path, file)
            print('src:', src)
            print('dst:', dst)
            shutil.move(src, dst)
        except:
            print("!!!!!!!!{}".format(file))
            pass

# 获取 E:\Python\test 目录下后缀为 .txt 文件数量和文件名
# path_file_num = glob.glob('D:\\protegeAuto_tool\\JsonCenter\\person\\*.json')
# print(path_file_num)
# print(len(path_file_num))
